/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package memoriavirtual;

import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author André
 */
public class JanelaPrincipal extends javax.swing.JFrame {

    /**
     * Creates new form JanelaPrincipal
     */
    public JanelaPrincipal() {
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup_Politica = new javax.swing.ButtonGroup();
        buttonGroup_Escopo = new javax.swing.ButtonGroup();
        jPanel_Configuracao = new javax.swing.JPanel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jTextField_TamMP = new javax.swing.JTextField();
        jTextField_TamMS = new javax.swing.JTextField();
        jTextField_TamQuadro = new javax.swing.JTextField();
        jButton_Iniciar = new javax.swing.JButton();
        jRadioButton_FIFO = new javax.swing.JRadioButton();
        jRadioButton_LRU = new javax.swing.JRadioButton();
        jLabel9 = new javax.swing.JLabel();
        jTextField_Instrucoes = new javax.swing.JTextField();
        jTextField_Processos = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        jTextField1_TamEndLogico = new javax.swing.JTextField();
        jLabel13 = new javax.swing.JLabel();
        jRadioButton_Local = new javax.swing.JRadioButton();
        jRadioButton_Global = new javax.swing.JRadioButton();
        jPanel_Memoria = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTable_MemoriaPrincipal = new javax.swing.JTable();
        jLabel2 = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        jTable_MemoriaSecundaria = new javax.swing.JTable();
        jPanel_Processos = new javax.swing.JPanel();
        jLabel4 = new javax.swing.JLabel();
        jButton_AbrirTP = new javax.swing.JButton();
        jScrollPane5 = new javax.swing.JScrollPane();
        jTable_Processos = new javax.swing.JTable();
        jPanel_Arquivo = new javax.swing.JPanel();
        jScrollPane3 = new javax.swing.JScrollPane();
        jTable_Instrucoes = new javax.swing.JTable();
        jLabel3 = new javax.swing.JLabel();
        jButton_ProximaInstrucao = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();
        jLabel14 = new javax.swing.JLabel();
        jLabel_EndReal = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowOpened(java.awt.event.WindowEvent evt) {
                formWindowOpened(evt);
            }
        });

        jPanel_Configuracao.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        jPanel_Configuracao.setName(""); // NOI18N

        jLabel5.setText("Configuração");

        jLabel6.setText("Tam da MP:");

        jLabel7.setText("Tam. da MS");

        jLabel8.setText("Tam. Quadro:");

        jButton_Iniciar.setText("Iniciar");
        jButton_Iniciar.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                jButton_IniciarMousePressed(evt);
            }
        });

        buttonGroup_Politica.add(jRadioButton_FIFO);
        jRadioButton_FIFO.setSelected(true);
        jRadioButton_FIFO.setText("FIFO");

        buttonGroup_Politica.add(jRadioButton_LRU);
        jRadioButton_LRU.setText("LRU");

        jLabel9.setText("Política de Substituição:");

        jLabel10.setText("Arq. Instruções:");

        jLabel11.setText("Arq. Processos:");

        jLabel12.setText("Tam. End. Lógico:");

        jLabel13.setText("Escopo Subst.:");

        buttonGroup_Escopo.add(jRadioButton_Local);
        jRadioButton_Local.setSelected(true);
        jRadioButton_Local.setText("Local");

        buttonGroup_Escopo.add(jRadioButton_Global);
        jRadioButton_Global.setText("Global");

        javax.swing.GroupLayout jPanel_ConfiguracaoLayout = new javax.swing.GroupLayout(jPanel_Configuracao);
        jPanel_Configuracao.setLayout(jPanel_ConfiguracaoLayout);
        jPanel_ConfiguracaoLayout.setHorizontalGroup(
            jPanel_ConfiguracaoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel_ConfiguracaoLayout.createSequentialGroup()
                .addGroup(jPanel_ConfiguracaoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel_ConfiguracaoLayout.createSequentialGroup()
                        .addGap(116, 116, 116)
                        .addComponent(jButton_Iniciar, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel_ConfiguracaoLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel12)))
                .addGap(0, 0, Short.MAX_VALUE))
            .addGroup(jPanel_ConfiguracaoLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel_ConfiguracaoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel_ConfiguracaoLayout.createSequentialGroup()
                        .addGroup(jPanel_ConfiguracaoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel10)
                            .addComponent(jLabel11))
                        .addGroup(jPanel_ConfiguracaoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel_ConfiguracaoLayout.createSequentialGroup()
                                .addGap(29, 29, 29)
                                .addComponent(jLabel5)
                                .addGap(0, 0, Short.MAX_VALUE))
                            .addGroup(jPanel_ConfiguracaoLayout.createSequentialGroup()
                                .addGap(26, 26, 26)
                                .addGroup(jPanel_ConfiguracaoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jTextField_Instrucoes)
                                    .addComponent(jTextField_Processos)))))
                    .addGroup(jPanel_ConfiguracaoLayout.createSequentialGroup()
                        .addGroup(jPanel_ConfiguracaoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel7)
                            .addComponent(jLabel6)
                            .addComponent(jLabel8))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGroup(jPanel_ConfiguracaoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jTextField_TamMS, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 228, Short.MAX_VALUE)
                            .addComponent(jTextField_TamQuadro, javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jTextField1_TamEndLogico, javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jTextField_TamMP)))
                    .addGroup(jPanel_ConfiguracaoLayout.createSequentialGroup()
                        .addGroup(jPanel_ConfiguracaoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel9)
                            .addComponent(jLabel13))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel_ConfiguracaoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jRadioButton_Local)
                            .addComponent(jRadioButton_FIFO))
                        .addGap(29, 29, 29)
                        .addGroup(jPanel_ConfiguracaoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jRadioButton_LRU)
                            .addComponent(jRadioButton_Global))
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addContainerGap())
        );
        jPanel_ConfiguracaoLayout.setVerticalGroup(
            jPanel_ConfiguracaoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel_ConfiguracaoLayout.createSequentialGroup()
                .addGap(5, 5, 5)
                .addComponent(jLabel5)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel_ConfiguracaoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextField_Instrucoes, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel10))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel_ConfiguracaoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextField_Processos, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel11))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel_ConfiguracaoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(jTextField_TamMP, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel_ConfiguracaoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel7)
                    .addComponent(jTextField_TamMS, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel_ConfiguracaoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel8)
                    .addComponent(jTextField_TamQuadro, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel_ConfiguracaoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel12)
                    .addComponent(jTextField1_TamEndLogico, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel_ConfiguracaoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel13)
                    .addComponent(jRadioButton_Global)
                    .addComponent(jRadioButton_Local))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel_ConfiguracaoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel9)
                    .addComponent(jRadioButton_FIFO)
                    .addComponent(jRadioButton_LRU))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 6, Short.MAX_VALUE)
                .addComponent(jButton_Iniciar)
                .addGap(13, 13, 13))
        );

        jPanel_Memoria.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));

        jLabel1.setText("Memória Principal");

        jTable_MemoriaPrincipal.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {

            }
        ));
        jScrollPane1.setViewportView(jTable_MemoriaPrincipal);

        jLabel2.setText("Memória Secundária");

        jTable_MemoriaSecundaria.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {

            }
        ));
        jScrollPane2.setViewportView(jTable_MemoriaSecundaria);

        javax.swing.GroupLayout jPanel_MemoriaLayout = new javax.swing.GroupLayout(jPanel_Memoria);
        jPanel_Memoria.setLayout(jPanel_MemoriaLayout);
        jPanel_MemoriaLayout.setHorizontalGroup(
            jPanel_MemoriaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel_MemoriaLayout.createSequentialGroup()
                .addContainerGap(334, Short.MAX_VALUE)
                .addComponent(jLabel2)
                .addGap(307, 307, 307))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel_MemoriaLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel_MemoriaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 717, Short.MAX_VALUE)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 717, Short.MAX_VALUE))
                .addContainerGap())
            .addGroup(jPanel_MemoriaLayout.createSequentialGroup()
                .addGap(319, 319, 319)
                .addComponent(jLabel1)
                .addContainerGap(336, Short.MAX_VALUE))
        );
        jPanel_MemoriaLayout.setVerticalGroup(
            jPanel_MemoriaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel_MemoriaLayout.createSequentialGroup()
                .addGap(19, 19, 19)
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 160, Short.MAX_VALUE)
                .addGap(18, 18, 18)
                .addComponent(jLabel2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 383, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        jPanel_Processos.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));

        jLabel4.setText("Processos");

        jButton_AbrirTP.setText("Abrir TP");
        jButton_AbrirTP.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButton_AbrirTPMouseClicked(evt);
            }
        });

        jTable_Processos.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {

            }
        ));
        jScrollPane5.setViewportView(jTable_Processos);

        javax.swing.GroupLayout jPanel_ProcessosLayout = new javax.swing.GroupLayout(jPanel_Processos);
        jPanel_Processos.setLayout(jPanel_ProcessosLayout);
        jPanel_ProcessosLayout.setHorizontalGroup(
            jPanel_ProcessosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel_ProcessosLayout.createSequentialGroup()
                .addGroup(jPanel_ProcessosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel_ProcessosLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))
                    .addGroup(jPanel_ProcessosLayout.createSequentialGroup()
                        .addGroup(jPanel_ProcessosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel_ProcessosLayout.createSequentialGroup()
                                .addGap(137, 137, 137)
                                .addComponent(jButton_AbrirTP))
                            .addGroup(jPanel_ProcessosLayout.createSequentialGroup()
                                .addGap(148, 148, 148)
                                .addComponent(jLabel4)))
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addContainerGap())
        );
        jPanel_ProcessosLayout.setVerticalGroup(
            jPanel_ProcessosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel_ProcessosLayout.createSequentialGroup()
                .addComponent(jLabel4)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 59, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 11, Short.MAX_VALUE)
                .addComponent(jButton_AbrirTP)
                .addContainerGap())
        );

        jPanel_Arquivo.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));

        jTable_Instrucoes.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {

            }
        ));
        jTable_Instrucoes.setEnabled(false);
        jScrollPane3.setViewportView(jTable_Instrucoes);

        jLabel3.setText("Instruções");

        jButton_ProximaInstrucao.setText("Proxima Instrução");
        jButton_ProximaInstrucao.setActionCommand("");
        jButton_ProximaInstrucao.setEnabled(false);
        jButton_ProximaInstrucao.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButton_ProximaInstrucaoMouseClicked(evt);
            }
        });

        javax.swing.GroupLayout jPanel_ArquivoLayout = new javax.swing.GroupLayout(jPanel_Arquivo);
        jPanel_Arquivo.setLayout(jPanel_ArquivoLayout);
        jPanel_ArquivoLayout.setHorizontalGroup(
            jPanel_ArquivoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel_ArquivoLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                .addContainerGap())
            .addGroup(jPanel_ArquivoLayout.createSequentialGroup()
                .addGap(149, 149, 149)
                .addComponent(jLabel3)
                .addGap(0, 0, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel_ArquivoLayout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jButton_ProximaInstrucao)
                .addGap(113, 113, 113))
        );
        jPanel_ArquivoLayout.setVerticalGroup(
            jPanel_ArquivoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel_ArquivoLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel3)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 58, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jButton_ProximaInstrucao)
                .addGap(6, 6, 6))
        );

        jPanel1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));

        jLabel14.setText("Endereço real:");

        jLabel_EndReal.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel14)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel_EndReal, javax.swing.GroupLayout.DEFAULT_SIZE, 253, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel14)
                    .addComponent(jLabel_EndReal, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel_Memoria, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel_Arquivo, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel_Processos, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel_Configuracao, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(14, 14, 14)
                        .addComponent(jPanel_Configuracao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jPanel_Processos, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jPanel_Arquivo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jPanel_Memoria, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void formWindowOpened(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowOpened
        instrucaoCorrente = -1;
        jTextField_Instrucoes.setText("entrada.txt");
        jTextField_Processos.setText("processos.txt");
    }//GEN-LAST:event_formWindowOpened

    private void jButton_ProximaInstrucaoMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton_ProximaInstrucaoMouseClicked
        if (instrucaoCorrente < jTable_Instrucoes.getRowCount() - 1) {
            instrucaoCorrente++;
            jTable_Instrucoes.setRowSelectionInterval(instrucaoCorrente, instrucaoCorrente);
            String[] linha = new String[3];
            linha[0] = InstrucoesModel.getValueAt(instrucaoCorrente, 0).toString();
            linha[1] = InstrucoesModel.getValueAt(instrucaoCorrente, 1).toString();
            linha[2] = InstrucoesModel.getValueAt(instrucaoCorrente, 2).toString();
            Main.MV_controller.leInstrucao(linha, Main.A_controller.getProcessos(), Integer.parseInt(jTextField1_TamEndLogico.getText()));
            Main.MV_controller.carregaMP();
            Main.MV_controller.carregaMS();
        }
    }//GEN-LAST:event_jButton_ProximaInstrucaoMouseClicked

    private void jButton_IniciarMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton_IniciarMousePressed
        try {

            int tamMP = Integer.parseInt(jTextField_TamMP.getText());
            int tamMS = Integer.parseInt(jTextField_TamMS.getText());
            int tamQuadro = Integer.parseInt(jTextField_TamQuadro.getText());
            int tamEndLogico = Integer.parseInt(jTextField1_TamEndLogico.getText());
            if ((tamMP + tamMS) % tamQuadro != 0) {
                JOptionPane.showMessageDialog(rootPane, "Tamanho da Memória física que deve ser múltiplo de tamanho do quadro");
                throw new Exception();
            }
            instrucaoCorrente = -1;
            Main.A_controller.carregaInstrucoes(jTextField_Instrucoes.getText());
            Main.A_controller.carregaProcessos(jTextField_Processos.getText(), tamQuadro);
            String politica = jRadioButton_FIFO.isSelected() ? "FIFO" : "LRU";
            String escopo = jRadioButton_Local.isSelected() ? "LOCAL" : "GLOBAL";
            Main.MV_controller.configurar(tamMP, tamMS, tamQuadro, tamEndLogico, Main.A_controller.getProcessos(), politica, escopo);
            Main.MV_controller.carregaMP();
            Main.MV_controller.carregaMS();
            this.jButton_ProximaInstrucao.setEnabled(true);
            JOptionPane.showMessageDialog(rootPane, "Valores válidos!");
        } catch (NumberFormatException nf) {
            JOptionPane.showMessageDialog(rootPane, "Números inválidos!");
        } catch (Exception e) {
        }
    }//GEN-LAST:event_jButton_IniciarMousePressed

    private void jButton_AbrirTPMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton_AbrirTPMouseClicked
       int processoCorrente = 0;
        try {
            processoCorrente = this.jTable_Processos.getSelectedRow();
            if (processoCorrente == -1) {
                JOptionPane.showMessageDialog(rootPane, "Escolha um processo.");
            } else {
                JanelaTP janela = new JanelaTP(this, false);
                janela.TPModel = Main.MV_controller.getTP(jTable_Processos.getValueAt(processoCorrente, 0).toString());
                janela.setTitle("TP: " + jTable_Processos.getValueAt(processoCorrente, 0).toString());
                janela.setVisible(true);
            }
        } catch (Exception e) {
            JOptionPane.showMessageDialog(rootPane, "A TP do processo " + jTable_Processos.getValueAt(processoCorrente, 0).toString() + " não foi criada !");
        }
    }//GEN-LAST:event_jButton_AbrirTPMouseClicked

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /*
         * Set the Nimbus look and feel
         */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /*
         * If Nimbus (introduced in Java SE 6) is not available, stay with the
         * default look and feel. For details see
         * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(JanelaPrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(JanelaPrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(JanelaPrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(JanelaPrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /*
         * Create and display the form
         */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new JanelaPrincipal().setVisible(true);
            }
        });
    }
    public int instrucaoCorrente;
    public DefaultTableModel InstrucoesModel;
    public DefaultTableModel ProcessosModel;
    public DefaultTableModel MemoriaSecundariaModel;
    public DefaultTableModel MemoriaPrincipalModel;
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.ButtonGroup buttonGroup_Escopo;
    private javax.swing.ButtonGroup buttonGroup_Politica;
    private javax.swing.JButton jButton_AbrirTP;
    private javax.swing.JButton jButton_Iniciar;
    private javax.swing.JButton jButton_ProximaInstrucao;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JLabel jLabel_EndReal;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel_Arquivo;
    private javax.swing.JPanel jPanel_Configuracao;
    private javax.swing.JPanel jPanel_Memoria;
    private javax.swing.JPanel jPanel_Processos;
    private javax.swing.JRadioButton jRadioButton_FIFO;
    private javax.swing.JRadioButton jRadioButton_Global;
    private javax.swing.JRadioButton jRadioButton_LRU;
    private javax.swing.JRadioButton jRadioButton_Local;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane5;
    public javax.swing.JTable jTable_Instrucoes;
    public javax.swing.JTable jTable_MemoriaPrincipal;
    public javax.swing.JTable jTable_MemoriaSecundaria;
    public javax.swing.JTable jTable_Processos;
    private javax.swing.JTextField jTextField1_TamEndLogico;
    private javax.swing.JTextField jTextField_Instrucoes;
    private javax.swing.JTextField jTextField_Processos;
    private javax.swing.JTextField jTextField_TamMP;
    private javax.swing.JTextField jTextField_TamMS;
    private javax.swing.JTextField jTextField_TamQuadro;
    // End of variables declaration//GEN-END:variables
}
